-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add events for row added and row updated #1101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@come-nc Why do we need these events for?
Ah, I guess related to Workflows? |
Yes! |
lib/Event/RowAddedEvent.php
Outdated
} | ||
|
||
public function getRow(): Row2 { | ||
return $this->row; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also have reservations about exposing the Entity. Turning this into a minified (and so serializable) model instance might could be a way. The Entity is can actually be json-serialized, that could be a base.
Then, in principle, whatever we are doing, we are de-facto exposing a Model to the outside, so setting standards as in an API, and have to keep them stable. That's generally fine, but would be a firstee at least in this app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just read the note about OCP\EventDispatcher\IWebhookCompatibleEvent
which is already in master meanwhile. But this is yet another jsonSerialize()
style method. In a way i still tend to a public model class that itself is just json serializable and we return the output here. On the other hand, this can be already done with the DB Entity.
I also noticed that we are actually exposing the DB Entities already in other events that are also released already. Including Row2.
@come-nc To evaluate what we want to pass along in the event, could you share more insights on the use case you're covering with your workflow task? |
Usecases are multiple:
I feel like putting the whole row content information in the event is too much because it may be a lot of data, while putting only the id allows to fetch the data from the API if needed. Not entirely sure. Maybe content but capped at a given maximum length would make sense? The event will need to be serialized by implementing upcomming |
8b92f0d
to
a43232d
Compare
Fixed conflicts, and added two changes (cf. my comments #1101 (comment) and #1101 (comment)). I added now a "Public" read-only Row model that is being attached to the Event. I am lacking a concept on how the IWebhookCompatibleEvent is supposed to be used (left a 1:1 message with @marcelklehr), but it should contain the necessary data. The acting user is left out (previously discussed with Côme). The Column(s) can be derived from the change sets. Not the Cell, it's probably not necessary, and we actually don't have that information ourselves. Especially since changed data is already debated. At the moment I send the row's values, and on update also the previous values. With Côme's statement:
It can be dropped indeed, return only the values that actually have changed (i.e. nothing on create and delete). Still can be a lot. Only the affected columns ids can be sent, too. What I am having in mind is if process changes shall be followed. E.g. Something may change from "pending" to "open", and from "closed" to "open" and different things shall happen then. Again, I am missing context down the line, whether this is something reasonable, or not relevant here. |
a43232d
to
29098c9
Compare
|
||
public function getWebhookSerializable(): array { | ||
return $this->row->jsonSerialize(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesomesauce!
270ff93
to
92a2a12
Compare
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
- implements OCP\EventDispatcher\IWebhookCompatibleEvent - add lib/Model/Public/Row as sort of API-like model for Tables Row data - change exisiting events to use new abstract row event class Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
otherwise we would see: ERROR: UndefinedClass - lib/Event/AbstractRowEvent.php:12:22 - Class, interface or enum named OCP\EventDispatcher\IWebhookCompatibleEvent does not exist (see https://psalm.dev/019) if (interface_exists(\OCP\EventDispatcher\IWebhookCompatibleEvent::class)) { Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
92a2a12
to
550a106
Compare
No description provided.